package reflect;

import java.lang.reflect.Field;

public class ReflectDemo7 {
    public static void main(String[] args) throws Exception {
        Class c=Class.forName("reflect.Teacher");
        Object o = c.newInstance();
        Field field = c.getField("name");
        Field field1 = c.getDeclaredField("age");
        field1.setAccessible(true);
        field.set(o,"ming");
        field1.set(o,18);
        System.out.println(field.get(o));
        System.out.println(field1.get(o));
        System.out.println(o);
        field1.setAccessible(false);
    }
}
